package com.example.testproject.activity

import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.ItemTouchHelper.UP
import com.example.testproject.R
import com.example.testproject.adapter.CardStackAdapter
import com.example.testproject.bean.CardStackBean
import com.example.testproject.call_back.SlideCardStackCallBack
import com.example.testproject.call_back.SlideCardStackCallBack2
import com.example.testproject.rv_layout_manager.CardStack2LayoutManager
import kotlinx.android.synthetic.main.recylcer_view.*

/**
 *
 * @ClassName: CardStackActivity
 * @Author: android 超级兵
 * @CreateDate: 10/21/21$ 11:04 AM$
 * TODO 叠加页面
 */
class CardStackActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.recylcer_view)

        rootRecyclerView.layoutManager = CardStack2LayoutManager()
//        rootRecyclerView.layoutManager = LinearLayoutManager(this)

        val cardStackAdapter = CardStackAdapter(initData())
        rootRecyclerView.adapter = cardStackAdapter

        // 创建拖拽
        val slideCardStackCallBack = SlideCardStackCallBack2(cardStackAdapter)

        Log.i("szjCallBack2","up:${ItemTouchHelper.UP}" +
                "\tdown:${ItemTouchHelper.DOWN}" +
                "\tleft:${ItemTouchHelper.LEFT}" +
                "\tright:${ItemTouchHelper.RIGHT}")

        val itemTouchHelper = ItemTouchHelper(slideCardStackCallBack)

        // 绑定拖拽
        itemTouchHelper.attachToRecyclerView(rootRecyclerView)
    }

    private fun initData() = let {
        arrayListOf(
            CardStackBean(R.mipmap.administration, "星期一", "心有多大,舞台就有多大。"),
            CardStackBean(R.mipmap.administration, "星期二", "亲爱的自己,只有想不到的,没有做不到的!加油!"),
            CardStackBean(
                R.mipmap.administration,
                "星期三",
                "相信梦想是价值的源泉,相信眼光决定未来的一切,相信成功的信念比成功本身更重要,相信人生有挫折没有失败,相信生命的质量来自决不妥协的信念。"
            ),
            CardStackBean(R.mipmap.administration, "星期四", "虽然我走得很慢,但我从不后退!"),
            CardStackBean(R.mipmap.administration, "星期五", "永远都不要放弃自己,勇往直前,直至成功!"),
            CardStackBean(R.mipmap.administration, "星期六", "事实上,成功谨代表你工作了1%,成功是99%失败的结果"),
            CardStackBean(R.mipmap.administration, "星期日", "让信仰坚持下去,梦想就会实现"),
        )
    }
}